package org.example.xls.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.example.xls.common.PageResult;
import org.example.xls.mapper.TestQuestionMapper;
import org.example.xls.pojo.TestQuestion;
import org.example.xls.pojo.TestRecordVO;
import org.example.xls.service.TestQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestQuestionServiceImpl implements TestQuestionService {
    @Autowired
    private TestQuestionMapper testQuestionMapper;
    @Override
    public List<TestQuestion> getTestQuestion(Integer testId) {
        return testQuestionMapper.getTestQuestion(testId);
    }

    @Override
    public Integer getCount(Integer testId) {
        return testQuestionMapper.getCount(testId);
    }

    /**
     * 测评记录分页查询
     * @param openId
     * @param page
     * @param size
     * @return
     */
    @Override
    public PageResult getTestQuestionPage(String openId, Integer page, Integer size) {
        PageHelper.startPage(page,size);
        Page<TestRecordVO> pageResult = testQuestionMapper.getTestQuestionPage(openId);
        return new PageResult(pageResult.getTotal(),pageResult.getResult());
    }
}
